package com.question.business.org.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.question.business.org.entity.OrgDept;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 机构部门Mapper接口
 *
 * @author star
 * @since 2023-09-15
 */
@Mapper
public interface OrgDeptMapper extends BaseMapper<OrgDept> {

    /**
     * 机构部门查询
     *
     * @param orgId 机构ID
     * @return List<String> 响应参数
     */
    @Select("SELECT dept_id FROM t_org_dept WHERE org_id = #{orgId}")
    List<String> queryDeptByOrgId(String orgId);

    /**
     * 部门机构查询
     *
     * @param deptId 部门ID
     * @return List<String> 响应参数
     */
    @Select("SELECT org_id FROM t_org_dept WHERE dept_id = #{deptId}")
    List<String> queryOrgByDeptId(String deptId);

    /**
     * 根据机构ID删除部门
     *
     * @param orgId 机构ID
     */
    @Delete("DELETE FROM t_org_dept WHERE org_id = #{orgId}")
    void deleteByOrgId(String orgId);

    /**
     * 根据部门ID删除机构
     *
     * @param deptId 部门ID
     */
    @Delete("DELETE FROM t_org_dept WHERE dept_id = #{deptId}")
    void deleteByDeptId(String deptId);
}